#include "test_list.h"

#ifdef TEST_FACTORY

#include <den/factory.h>


#define TEST_CASE_NAME Den
#define TEST_NUMBER(n) Factory##_##n


#define TEST_FACTORY_000
#define TEST_FACTORY_001
#define TEST_FACTORY_002
#define TEST_FACTORY_003
#define TEST_FACTORY_004
#define TEST_FACTORY_005
#define TEST_FACTORY_006
#define TEST_FACTORY_007
#define TEST_FACTORY_008
#define TEST_FACTORY_009
#define TEST_FACTORY_010
#define TEST_FACTORY_011
#define TEST_FACTORY_012
#define TEST_FACTORY_013
#define TEST_FACTORY_014
#define TEST_FACTORY_015
#define TEST_FACTORY_016
#define TEST_FACTORY_017
#define TEST_FACTORY_018
#define TEST_FACTORY_019
#define TEST_FACTORY_020
#define TEST_FACTORY_021
#define TEST_FACTORY_022
#define TEST_FACTORY_023
#define TEST_FACTORY_024
#define TEST_FACTORY_025
#define TEST_FACTORY_026
#define TEST_FACTORY_027
#define TEST_FACTORY_028
#define TEST_FACTORY_029
#define TEST_FACTORY_030
#define TEST_FACTORY_031
#define TEST_FACTORY_032

//------------------------------------------------------------------------------------------------------//

namespace{

struct IWorker
{
    typedef ::std::string
        Str;
    typedef ::std::vector<Str>
        VecStr;

    virtual ~IWorker(){}
    IWorker(const Str& name = "IWorker",const size_t num=0)
        :mName(name)
        ,mNum(num)
    {}

    const Str& GetName()const { return mName; }

    virtual int Work()=0;
    virtual void OnInit(const size_t num) { mNum = num; }

    Str     mName;
    size_t  mNum;
};

struct Worker1: IWorker
{
    Worker1(const Str& name = "IWorker",const size_t num=0)
        :IWorker(name,num)
    {}
    virtual int Work(){ cout<< mName<< " working...\n"; return 1; }
};

typedef TFactory<IWorker> Factory;

}//namespace
//------------------------------------------------------------------------------------------------------//

#ifdef TEST_FACTORY_000
TEST(TEST_CASE_NAME, TEST_NUMBER(000))
{
    Factory::Add<Worker1>("Worker1");

    auto names1 = Factory::GetNames();
    const auto num1 = names1.size();
    EXPECT_EQ(1, num1 );
    if(num1==1)
        EXPECT_EQ("Worker1", names1[0]);

    auto& worker = Factory::Build("Worker1");
    auto re = worker.Work();
    EXPECT_EQ(1, re );

    Factory::Del("Worker1");
    EXPECT_EQ(0, Factory::GetNames().size() );
}
#endif // TEST_FACTORY_000

#ifdef TEST_FACTORY_001
#endif // TEST_FACTORY_001

#ifdef TEST_FACTORY_002
#endif // TEST_FACTORY_002

#ifdef TEST_FACTORY_003
#endif // TEST_FACTORY_003

#ifdef TEST_FACTORY_004
#endif // TEST_FACTORY_004

#ifdef TEST_FACTORY_005
#endif // TEST_FACTORY_005

#ifdef TEST_FACTORY_006
#endif // TEST_FACTORY_006

#ifdef TEST_FACTORY_007
#endif // TEST_FACTORY_007

#ifdef TEST_FACTORY_008
#endif // TEST_FACTORY_008

#ifdef TEST_FACTORY_009
#endif // TEST_FACTORY_009

#ifdef TEST_FACTORY_010
#endif // TEST_FACTORY_010

#ifdef TEST_FACTORY_011
#endif // TEST_FACTORY_011

#ifdef TEST_FACTORY_012
#endif // TEST_FACTORY_012

#ifdef TEST_FACTORY_013
#endif // TEST_FACTORY_013

#ifdef TEST_FACTORY_014
#endif // TEST_FACTORY_014

#ifdef TEST_FACTORY_015
#endif // TEST_FACTORY_015

#ifdef TEST_FACTORY_016
#endif // TEST_FACTORY_016

#ifdef TEST_FACTORY_017
#endif // TEST_FACTORY_017

#ifdef TEST_FACTORY_018
#endif // TEST_FACTORY_018

#ifdef TEST_FACTORY_019
#endif // TEST_FACTORY_019

#ifdef TEST_FACTORY_020
#endif // TEST_FACTORY_020

#ifdef TEST_FACTORY_021
#endif // TEST_FACTORY_021

#ifdef TEST_FACTORY_022
#endif // TEST_FACTORY_022

#ifdef TEST_FACTORY_023
#endif // TEST_FACTORY_023

#ifdef TEST_FACTORY_024
#endif // TEST_FACTORY_024

#ifdef TEST_FACTORY_025
#endif // TEST_FACTORY_025

#ifdef TEST_FACTORY_026
#endif // TEST_FACTORY_026

#ifdef TEST_FACTORY_027
#endif // TEST_FACTORY_027

#ifdef TEST_FACTORY_028
#endif // TEST_FACTORY_029

#ifdef TEST_FACTORY_030
#endif // TEST_FACTORY_030

#ifdef TEST_FACTORY_031
#endif // TEST_FACTORY_031

#ifdef TEST_FACTORY_032
#endif // TEST_FACTORY_032

#endif



